package com.ffzx.commerce.framework.system.entity;

import java.util.ArrayList;
import java.util.List;

import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.ffzx.commerce.framework.common.persistence.TreeEntity;

/**
 * 机构Entity
 * 
 * @author zhugj
 * @date 2016年3月1日 下午2:03:29
 * @version 0.1.0
 */
public class SysOffice extends TreeEntity<SysOffice> {

	private static final long serialVersionUID = 1L;
	//@NotNull
	private SysArea area;		// 归属区域
	@NotNull
	@Length(min=0, max=50)
	private String code; 	// 机构编码
	@Length(min=1, max=1,message="请选组织类别")
	private String type; 	// 机构类型（1：公司；2：部门；3：小组）
	@Length(max=1)				//@Length(min=1, max=1,message="请选择机构等级")
	private String grade; 	// 机构等级（1：一级；2：二级；3：三级；4：四级）
	@Length(min=0, max=255)
	private String address; // 联系地址
	@Length(min=0, max=100)
	private String zipCode; // 邮政编码
	@Length(min=0, max=100)
	private String master; 	// 负责人
	@Length(min=0, max=200)
	private String phone; 	// 电话
	@Length(min=0, max=200)
	private String fax; 	// 传真
	@Length(min=0, max=200)
	private String email; 	// 邮箱
	private String useable;//是否可用
	private SysUser primaryPerson;//主负责人
	private SysUser deputyPerson;//副负责人
	private List<String> childDeptList;//快速添加子部门
	private List<SysOffice> sub;
	private String roleId;
	
	private int childeren;

	
	//树节点判断是否有展开功能的
    private boolean isParent = false;
    
	public boolean getIsParent() {
		if (childeren > 0) {
			this.isParent = true;
		}
		return isParent;
	}

	/**
	 * 部门属性
	 */
	//@Length(max=1)		@Length(min=1, max=1,message="请选择部门属性")
	private String deptAttr;
	
	public SysOffice(){
		super();
//		this.type = "2";
	}

	public SysOffice(String id){
		super(id);
	}
	
	public List<String> getChildDeptList() {
		return childDeptList;
	}

	public void setChildDeptList(List<String> childDeptList) {
		this.childDeptList = childDeptList;
	}

	public String getUseable() {
		return useable;
	}

	public void setUseable(String useable) {
		this.useable = useable;
	}

	public SysUser getPrimaryPerson() {
		return primaryPerson;
	}

	public void setPrimaryPerson(SysUser primaryPerson) {
		this.primaryPerson = primaryPerson;
	}

	public SysUser getDeputyPerson() {
		return deputyPerson;
	}

	public void setDeputyPerson(SysUser deputyPerson) {
		this.deputyPerson = deputyPerson;
	}

	public SysOffice getParent() {
		return parent;
	}

	public void setParent(SysOffice parent) {
		this.parent = parent;
	}

	public SysArea getArea() {
		return area;
	}

	public void setArea(SysArea area) {
		this.area = area;
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getGrade() {
		return grade;
	}

	public void setGrade(String grade) {
		this.grade = grade;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public String getMaster() {
		return master;
	}

	public void setMaster(String master) {
		this.master = master;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	public String toString() {
		return name;
	}
	
	public List<SysOffice> getSub() {
		if(sub == null){
			sub = new ArrayList<SysOffice>();
		}
		return sub;
	}

	public void setSub(List<SysOffice> sub) {
		this.sub = sub;
	}

	public String getRoleId() {
		return roleId;
	}

	public void setRoleId(String roleId) {
		this.roleId = roleId;
	}

	public String getDeptAttr() {
		return deptAttr;
	}

	public void setDeptAttr(String deptAttr) {
		this.deptAttr = deptAttr;
	}
	
	public int getChilderen() {
		return childeren;
	}

	public void setChilderen(int childeren) {
		this.childeren = childeren;
	}
}
